﻿namespace Basmus.Conel
{
    public class StringBinding : Binding
       
    {
        public StringBinding()
            : base(typeof(string))
        {

        }

        public override object[] GetElements(object container)
        {
            if (container == null)
                return null;
            var s = (string) container;
            if (s == string.Empty)
                return new object[0];
            return new[] {s};
        }

        public override object GetContainer(object[] elements)
        {
            if (elements == null)
                return null;
            if (elements.Length == 0)
                return string.Empty;
            if (elements[0] == null)
                return string.Empty;
            var container = (string) elements[0];
            return container;

        }
    }
}
